#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;
class Solution {
public:
    bool backspaceCompare(string s, string t) {
        string as;
        string aq;
        for (int i = 0; i < s.size(); i++)
        {
            if (as.size() && s[i] == '#')
            {
                as.pop_back();
            }
            if (s[i] != '#')
            {
                as += s[i];
            }
        }
        for (int j = 0; j < t.size(); j++)
        {
            if (aq.size() && t[j] == '#')
            {
                aq.pop_back();
            }
            if (t[j] != '#')
            {
                aq += t[j];
            }
        }
        if (as == aq)
            return true;
        return false;
    }
};